from UserList import UserList
from random import shuffle
import logging
import toolbox

__author__ = "Massimo Bonvicini"
__date__ = "$Jun 25, 2009 12:08:38 PM$"


log = logging.getLogger(__name__)

class Deck(UserList):
    showList = ['name', 'cards']
    
    def __init__(self, name, cards=[]):
        UserList.__init__(self, cards)
        self.id = toolbox.genID(name)
        self.owner = None
        self.name = name
        for card in cards:
            card.setDeck(self)
        shuffle(self)
#        log.info(self)

    def __repr__(self):
        return toolbox.str_impl(self, self.showList)
        
    def __str__(self):
        return repr(self)
        
    def setOwner(self, owner):
        self.owner = owner
        for card in self:
            card.setOwner(owner)